
package com.spica.spicaschool.network.service

import com.skydoves.sandwich.ApiResponse
import com.spica.spicaschool.bean.UpdateUserInfoResponse
import com.spica.spicaschool.bean.User
import com.spica.spicaschool.bean.UserBody
import com.spica.spicaschool.bean.diary.Diary
import com.spica.spicaschool.bean.group.Group
import com.spica.spicaschool.bean.news.NewsResponse
import com.spica.spicaschool.bean.newsdetail.NewsDetailResponse
import com.spica.spicaschool.network.ResponseList
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

const val POST_TYPE = 1 //动态
const val ARTICLE_TYPE = 4 //资讯
const val QUESTION_TYPE = 3 //问题
const val CONSULT_TYPE = 2 //咨询
const val DIARY_TYPE = 5 //日记

interface SpicaSchoolService {

    //获取用户数据
    @POST("user/userInfo")
    suspend fun fetchUserInfo(@Query("token") token: String): ApiResponse<ResponseList<User>>

    //获取用户身体信息
    @POST("user/userBodyInfo")
    suspend fun fetchUserBodyInfo(@Query("token") token: String): ApiResponse<ResponseList<UserBody>>

    //更新用户信息
    @POST("user/updateUser")
    suspend fun updateUser(
        @Query("token") token: String,
        @Query("head") head: String? = null,
        @Query("nickName") nickname: String? = null,
        @Query("selfdes") selfdes: String? = null,
        @Query("gender") gender: Int? = null,
        @Query("birthday") birthday: String? = null,
        @Query("height") height: Int? = null,
        @Query("weight") weight: Int? = null,
        @Query("vialCap") vialCap: Int? = null
    ): ApiResponse<UpdateUserInfoResponse>

    //获取圈子中的信息流
    @POST("diary/cicle")
    suspend fun fetchCircleDiaries(
        @Query("type") type: Int,
        @Query("token") token: String,
        @Query("pageNum") pageNum: Int,
        @Query("pageSize") pageSize: Int
    ): ApiResponse<ResponseList<Diary>>


    /**
     * 新闻列表
     */
    @GET("https://www.jsanai.com/api/selfnews/newslist")
    suspend fun fetchNews(
        @Query("type") type: Int = 3,
        @Query("page") page: Int,
        @Query("psize") psize: Int = 20
    ): ApiResponse<NewsResponse>


    @GET("https://www.jsanai.com/api/selfnews/newsd")
    suspend fun fetchNewsDetail(@Query("id") id: String): ApiResponse<NewsDetailResponse>

    /**
     * 获取对应类型的信息流列表
     */
    @POST("diary/list")
    suspend fun fetchDiaries(
        @Query("type") type: Int,
        @Query("token") token: String,
        @Query("pageNum") pageNum: Int,
        @Query("pageSize") pageSize: Int
    ): ApiResponse<ResponseList<Diary>>


    @POST("team/list")
    suspend fun fetchgroups(
        @Query("token") token: String,
        @Query("pageNum") pageNum: Int,
        @Query("pageSize") pageSize: Int
    ): ApiResponse<ResponseList<Group>>


}